import React from 'react';
import { Provider } from 'react-redux';
import dynamic from 'next/dynamic';
import App from 'next/app';
import Head from 'next/head';
// import * as Sentry from '@sentry/react';
import { Integrations } from '@sentry/tracing';
import { Layout } from '../components';
import withRematch from '../store/withRematch';
// import { SENTRY_DSN } from '../consts';
import './rest.css';

class MyApp extends App {
  static async getInitialProps({ Component, ctx }) {
    return {
      pageProps: Component.getInitialProps ? await Component.getInitialProps(ctx) : {},
      seoData: ctx.req?.seoData || {},
    };
  }

  render() {
    const { Component, pageProps, store, seoData } = this.props;
    return (
      <>
        <Head>
          <title>{seoData?.title || 'SSR'}</title>
          <meta name="keywords" content={seoData?.keywords || ''} />
          <meta name="description" content={seoData?.description || ''} />
          <link rel="icon" href="https://img.kaikeba.com/a/82815192501202xocl.ico" />
        </Head>
        <Provider store={store}>
          <Layout>
            <Component {...pageProps} />
          </Layout>
        </Provider>
      </>
    );
  }
}

export default withRematch(MyApp);
